home *** CD-ROM | disk | FTP | other *** search
- option add *Listbox*font \
- "-*-helvetica-medium-r-normal-*-12-*-*-*-p-*-iso8859-1" startupFile
- option add *Entry*font \
- "-*-helvetica-medium-r-normal-*-12-*-*-*-p-*-iso8859-1" startupFile
- option add *Label*font \
- "-*-helvetica-medium-r-normal-*-12-*-*-*-p-*-iso8859-1" startupFile
-
- # this is the default proc called when "OK" is pressed
- # indicate your own proc as an argument to prefs
-
- set windowed 0
- set throttle 0
- set vmode "opengl"
-
- proc prefs.default.cmd {f} {
- global prefs
- destroy $w
- }
-
-
- # this is the default proc called when error is detected
- # indicate your own proc as an argument to prefs
-
- proc prefs.default.errorHandler {errorMessage} {
- puts stdout "error: $errorMessage"
- catch { cd ~ }
- }
-
- # this is the proc that creates the prefs window
-
- proc prefs {
- {cmd prefs.default.cmd}
- {w .prefsWindow}
- {errorHandler prefs.default.errorHandler}} {
- global windowed
- global throttle
- global vmode
- catch {destroy $w}
-
- toplevel $w
- grab $w
- wm title $w "Preferences"
-
- set fl [open "| ./uimodeidx.sh"]
- gets $fl cur_uimodeidx
- if {[catch {close $fl} err]} {
- puts "Failed to read current ui mode key: $err"
- }
- set fl [open "| ./getoption.sh window"]
- gets $fl cur_window
- if {[catch {close $fl} err]} {
- puts "Failed to read current window mode: $err"
- }
- set fl [open "| ./getoption.sh throttle"]
- gets $fl cur_throttle
- if {[catch {close $fl} err]} {
- puts "Failed to read current throttle setting: $err"
- }
- set fl [open "| ./getoption.sh video"]
- gets $fl cur_video
- if {[catch {close $fl} err]} {
- puts "Failed to read current video setting: $err"
- }
-
-
- # path independent names for the widgets
- global prefs
- set prefs(uikeylst) $w.prefs.sframe.uikeylst
- set prefs(scroll) $w.prefs.sframe.scroll
- set prefs(ok) $w.bframe.okframe.ok
-
- # widgets
- frame $w.prefs -bd 5
- frame $w.bframe -bd 5
- pack append $w \
- $w.prefs {top filly} \
- $w.bframe {bottom expand frame n}
-
- frame $w.prefs.sframe
-
- pack append $w.prefs \
- $w.prefs.sframe {top fillx}
-
- label $w.prefs.sframe.uikeylab -text "Select UI Mode key"
- listbox $w.prefs.sframe.uikeylst -relief sunken -selectmode single \
- -yscroll "$w.prefs.sframe.yscroll set"
- scrollbar $w.prefs.sframe.yscroll -relief sunken \
- -command "$w.prefs.sframe.uikeylst yview"
- source uikeylst.tcl
- $w.prefs.sframe.uikeylst selection set $cur_uimodeidx
- $w.prefs.sframe.uikeylst see $cur_uimodeidx
- pack append $w.prefs.sframe \
- $w.prefs.sframe.uikeylab {top} \
- $w.prefs.sframe.yscroll {right filly} \
- $w.prefs.sframe.uikeylst {left expand fill}
-
- # buttons
- frame $w.bframe.okframe -borderwidth 2
-
- label $w.bframe.okframe.vlab -text "Video mode"
- set vvalues [list]
- lappend vvalues "opengl"
- lappend vvalues "soft"
- spinbox $w.bframe.okframe.vmode -textvariable vmode -values $vvalues
- set vmode $cur_video
-
- checkbutton $w.bframe.okframe.win -text "Run in a window" -variable windowed
- if {$cur_window==1} {
- $w.bframe.okframe.win select
- }
- checkbutton $w.bframe.okframe.throt -text "Throttle" -variable throttle
- if {$cur_throttle==1} {
- $w.bframe.okframe.throt select
- }
- button $w.bframe.okframe.ok -text OK -relief raised \
- -command "prefs.ok.cmd $w $cmd $errorHandler"
-
- pack append $w.bframe.okframe \
- $w.bframe.okframe.vlab {top} \
- $w.bframe.okframe.vmode {top} \
- $w.bframe.okframe.win {top} \
- $w.bframe.okframe.throt {top} \
- $w.bframe.okframe.ok {bottom}
-
- pack append $w.bframe $w.bframe.okframe {expand padx 5 pady 5}
-
- }
-
-
- # auxiliary button procedures
-
- proc prefs.ok.cmd {w cmd errorHandler} {
- global prefs
- global windowed
- global throttle
- global vmode
- global MESSHOME
- global messdir
- set uimodenum [$prefs(uikeylst) curselection]
- set uimodekey [$prefs(uikeylst) get $uimodenum]
- set currdir [pwd]
- if [catch {exec ./resetini.sh} errors] {
- tk_messageBox -default ok -message "Error running shell script" -type ok
- }
- cd "$MESSHOME"
- set command "exec '$messdir/mess' -uimodekey $uimodekey -video $vmode"
- if {$windowed==1} {
- set command "$command -window"
- }
- if {$throttle==1} {
- set command "$command -throttle"
- }
- set command "$command -createconfig"
- puts $command
- if [catch {exec /bin/sh -c $command} errors] {
- tk_messageBox -default ok -message "Error running \"$command\"" -type ok
- }
- cd "$currdir"
- destroy $w
- }
-